<%--
    Document   : index
    Created on : 09 Apr 11, 0:21:47
    Author     : asus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="database.db" %>
<%@page import="bean.*" %>
<%@page import="java.util.ArrayList" %>

<%
    db.setConnection();
    ArrayList<category> c = db.getcategories();
    ArrayList<user> u;
    
    String uid = (session.getAttribute("uid")).toString();
    String uname = (session.getAttribute("username")).toString();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../css/style.css"/>
        <script type="text/javascript" src="../js/admin.js"></script>
        <title>popoChat</title>
        <title>User</title>
    </head>

    <body>
        <% if (uid != null) { %>
            <div class="main_wrapper">
                <div class="login">
                    <div class="logininput">
                        <div class="logout">
                            <a href="../logout" onclick=""><img src="../image/exit.png" alt="logout" id="logout"/></a>
                            logout
                        </div>
                        <% if (uname != null) { %>
                        <div id="activeUsername">
                            <label>you are logged in as <b><%= uname %></b></label>
                        </div>
                        <% } %>
                    </div>
                </div>

                <div class="admin_content">
                    <div class="up_area">
                        <div class="admin_ititle">
                            Category
                        </div>
                        <div class="admin_content_wrapper">
                            <div id="addCategory">
                                <form method="post" action="../addcategory">
                                <div class="ilabelcateg">
                                    <div>Add Category</div>
                                    <div class="labelcategoryname">Category Name</div>
                                    <div class="labelcategoryname">Parent Category</div>
                                </div>
                                <div class="contentcateg">
                                    <br />
                                    <input type="text" id="addcategory" name="name">
                                    <select id="add_category" class="idropdown2" name="parent">
                                        <option value="0">root</option>
                                        <% for(int i=0; i<c.size(); i++){ %>
                                        <option value="<%= c.get(i).getId() %>"><%= c.get(i).getName() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                <br/>
                                <input type="button" class="isubmit2" onclick="if(validateAddCategory()) submit()" value="add">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <hr color="#7972AB"/>

                            <div id="deleteCategory">
                                <form method="POST" action="../deletecategory">
                                <div class="ilabelcateg">Delete Category</div>
                                    <div class="contentcateg">
                                        <select id="del_category" class="idropdown2" name="id">
                                            <option value="0">not selected</option>
                                            <%
                                                for(int i=0; i<c.size(); i++){
                                            %>
                                            <option value="<%= c.get(i).getId() %>"><%= c.get(i).getName() %></option>
                                            <% } %>
                                        </select>
                                    </div>
                                        <input type="button" class="isubmit2" onclick="if(validateRemoveCategory()) submit()" value="delete">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <hr color="#7972AB"/>

                            <div id="changeCategory">
                                <form method="POST" action="../changecategory">
                                <div class="ilabelcateg">
                                    <div>Update Info Category</div>
                                    <div class="labelcategoryname">Category Name</div>
                                    <div class="labelcategoryname">Parent Category</div>
                                </div>
                                <div class="contentcateg">
                                    <select id="choose_category" class="idropdown2" name="idcategory">
                                        <option value="0">not selected</option>
                                        <% for(int i=0; i<c.size(); i++){ %>
                                        <option value="<%= c.get(i).getId() %>"><%= c.get(i).getName() %></option>
                                        <% } %>
                                    </select>
                                    <div class="editcateg">
                                        <input type="text" id="editcategory" name="nama">
                                    </div>
                                    <select id="choose_parentcategory" class="idropdown2" name="parent">
                                        <option value="0">root</option>
                                        <% for(int i=0; i<c.size(); i++){ %>
                                        <option value="<%= c.get(i).getId() %>"><%= c.get(i).getName() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                    <input type="button" class="isubmit2" onclick="if(validateUpdateCategory()) submit()" value="update">
                                <div class="clear"></div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="down_area">
                        <div class="admin_ititle">
                            Moderator and User Setting
                        </div>
                        <div class="admin_content_wrapper">

                            <div id="addModerator">
                                <form method="POST" action="../addmoderator">
                                <div class="ilabelcateg">
                                    <div>Add Moderator</div>
                                    <div class="labelcategoryname">Category</div>
                                </div>
                                <div class="contentcateg">
                                    <% u = db.getusers(); %>
                                    <select id="selectmoderator_user" class="idropdown2" name="user">
                                        <option value="0">not selected</option>
                                        <% for(int i=0; i<u.size(); i++){ %>
                                        <option value="<%= u.get(i).getId() %>"><%= u.get(i).getUsername() %></option>
                                        <% } %>
                                    </select>
                                    <select id="selectmoderator_category" class="idropdown2" name="category">
                                        <option value="0">root</option>
                                        <% for(int i=0; i<c.size(); i++){ %>
                                        <option value="<%= c.get(i).getId() %>"><%= c.get(i).getName() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                    <input type="button" class="isubmit2" onclick="if(validateAddModerator()) submit()" value="add">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <div id="removeModerator">
                                <form method="POST" action="../delmoderator">
                                <div class="ilabelcateg">Remove Moderator</div>
                                <div class="contentcateg">
                                    <% ArrayList<moderator> m = db.getmoderators(); %>
                                    <select id="select_remModerator" class="idropdown2" name="moderator">
                                        <option value="0">not selected</option>
                                        <% for(int i=0; i<m.size(); i++){ %>
                                        <option value="<%= m.get(i).getId() %>"><%= m.get(i).getUsername() %>-<%= m.get(i).getNamaKategori() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                    <input type="button" class="isubmit2" onclick="if(validateDelModerator()) submit()" value="remove">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <hr color="#7972AB"/>

                            <div id="banUser">
                                <form method="POST" action="../banuser">
                                <div class="ilabelcateg">Ban User</div>
                                <div class="contentcateg">
                                    <% u = db.getusernotbanned(); %>
                                    <select id="select_banUser" class="idropdown2" name="select_banUser">
                                        <option value="0">not selected</option>
                                        <% for(int i=0; i<u.size(); i++){ %>
                                        <option value="<%= u.get(i).getId() %>"><%= u.get(i).getUsername() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                <input type="button" class="isubmit2" onclick="if(validateBan()) submit()" value="ban">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <div id="unbanUser">
                                <form method="POST" action="../unbanuser">
                                <div class="ilabelcateg">Unban User</div>
                                <div class="contentcateg">
                                    <% u = db.getuserbanned(); %>
                                    <select id="select_unbanUser" class="idropdown2" name="select_unbanUser">
                                        <option value="0">not selected</option>
                                        <% for(int i=0; i<u.size(); i++){ %>
                                        <option value="<%= u.get(i).getId() %>"><%= u.get(i).getUsername() %></option>
                                        <% } %>
                                    </select>
                                </div>
                                    <input type="button" class="isubmit2" onclick="if(validateUnban()) submit()" value="unban">
                                <div class="clear"></div>
                                </form>
                            </div>

                            <hr color="#7972AB"/>

                            <div id="setMaxRoom">
                                <form method="POST" action="../setmaxroom">
                                <div class="ilabelcateg">Set Max Room</div>
                                <div class="contentcateg">
                                    <input type="text" name="maxroom" id="setmax" value="<%= db.getmaxroom() %>">
                                </div>
                                <input type="button" class="isubmit2" onclick="if(validateMaxRoom()) submit()" value="set">
                                <div class="clear"></div>
                                </form>
                            </div>

                        </div>
                    </div>
                </div>

                <div id="footer">
                    Created by Ana - Edwin - Athia
                </div>
            </div>
        <% } else { %>
            <%@include file="../index.jsp" %>
        <% } %>
    </body>
</html>
<% db.unsetConnection(); %>